// 渲染函数
function getHeadImg(){

    axios.get('/my/user/userinfo')
    .then(res => {
        // console.log(res)
        let username = res.data.data.nickname||res.data.data.username
        $('.username').text(username).css({'display':'inline-block'});        
        if(res.data.data.user_pic ===null){
            let first = username.substring(0,1);
            $('.text-avatar').text(first).css({'display':'inline-block'});
        }else{
            let pic = res.data.data.user_pic;
            $('.layui-nav-img').css({'display':'block'})[0].src = pic;
        }
    })
   
}
getHeadImg();



// 退出

$('.logout').on('click',function () {

    location.href = './login.html'
    localStorage.removeItem('token')
})